
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module TermEmulator</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>TermEmulator</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/cgroza/Projects/gEcrit/bin/TermEmulator.py">/home/cgroza/Projects/gEcrit/bin/TermEmulator.py</a></font></td></tr></table>
    <p><tt>#&nbsp;-*-&nbsp;coding:&nbsp;utf-8&nbsp;-*-</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="pty.html">pty</a><br>
</td><td width="25%" valign=top><a href="select.html">select</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="TermEmulator.html#V102Terminal">V102Terminal</a>
</font></dt></dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="V102Terminal">class <strong>V102Terminal</strong></a></font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Emulator&nbsp;for&nbsp;VT100&nbsp;terminal&nbsp;programs.<br>
&nbsp;<br>
This&nbsp;module&nbsp;provides&nbsp;terminal&nbsp;emulation&nbsp;for&nbsp;VT100&nbsp;terminal&nbsp;programs.&nbsp;It&nbsp;handles<br>
V100&nbsp;special&nbsp;characters&nbsp;and&nbsp;most&nbsp;important&nbsp;escape&nbsp;sequences.&nbsp;It&nbsp;also&nbsp;handles<br>
graphics&nbsp;rendition&nbsp;which&nbsp;specifies&nbsp;text&nbsp;style(i.e.&nbsp;bold,&nbsp;italics),&nbsp;foreground&nbsp;color<br>
and&nbsp;background&nbsp;color.&nbsp;The&nbsp;handled&nbsp;escape&nbsp;sequences&nbsp;are&nbsp;CUU,&nbsp;CUD,&nbsp;CUF,&nbsp;CUB,&nbsp;CHA,<br>
CUP,&nbsp;ED,&nbsp;EL,&nbsp;VPA&nbsp;and&nbsp;SGR.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="V102Terminal-Clear"><strong>Clear</strong></a>(self)</dt><dd><tt>Clears&nbsp;the&nbsp;entire&nbsp;terminal&nbsp;screen</tt></dd></dl>

<dl><dt><a name="V102Terminal-ClearRect"><strong>ClearRect</strong></a>(self, startRow, startCol, endRow, endCol)</dt><dd><tt>Clears&nbsp;the&nbsp;terminal&nbsp;screen&nbsp;starting&nbsp;from&nbsp;startRow&nbsp;and&nbsp;startCol&nbsp;to<br>
endRow&nbsp;and&nbsp;EndCol.</tt></dd></dl>

<dl><dt><a name="V102Terminal-Dump"><strong>Dump</strong></a>(self, file<font color="#909090">=&lt;open file '&lt;stdout&gt;', mode 'w'&gt;</font>)</dt><dd><tt>Dumps&nbsp;the&nbsp;entire&nbsp;terminal&nbsp;screen&nbsp;into&nbsp;the&nbsp;given&nbsp;file/stdout</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetChar"><strong>GetChar</strong></a>(self, row, col)</dt><dd><tt>Returns&nbsp;the&nbsp;character&nbsp;at&nbsp;the&nbsp;location&nbsp;specified&nbsp;by&nbsp;row&nbsp;and&nbsp;col.&nbsp;The<br>
row&nbsp;and&nbsp;col&nbsp;should&nbsp;be&nbsp;in&nbsp;the&nbsp;range&nbsp;0..rows&nbsp;-&nbsp;1&nbsp;and&nbsp;0..cols&nbsp;-&nbsp;1."</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetCols"><strong>GetCols</strong></a>(self)</dt><dd><tt>Returns&nbsp;no.&nbsp;cols&nbsp;in&nbsp;the&nbsp;terminal</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetCursorPos"><strong>GetCursorPos</strong></a>(self)</dt><dd><tt>Returns&nbsp;cursor&nbsp;position&nbsp;as&nbsp;tuple</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetDirtyLines"><strong>GetDirtyLines</strong></a>(self)</dt><dd><tt>Returns&nbsp;list&nbsp;of&nbsp;dirty&nbsp;lines(line&nbsp;nos)&nbsp;since&nbsp;last&nbsp;call&nbsp;to&nbsp;GetDirtyLines.<br>
The&nbsp;line&nbsp;no&nbsp;will&nbsp;be&nbsp;0..rows&nbsp;-&nbsp;1.</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetLine"><strong>GetLine</strong></a>(self, lineno)</dt><dd><tt>Returns&nbsp;the&nbsp;terminal&nbsp;screen&nbsp;line&nbsp;specified&nbsp;by&nbsp;lineno.&nbsp;The&nbsp;line&nbsp;is<br>
returned&nbsp;as&nbsp;string,&nbsp;blank&nbsp;space&nbsp;represents&nbsp;empty&nbsp;character.&nbsp;The&nbsp;lineno<br>
should&nbsp;be&nbsp;in&nbsp;the&nbsp;range&nbsp;0..rows&nbsp;-&nbsp;1</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetLines"><strong>GetLines</strong></a>(self)</dt><dd><tt>Returns&nbsp;terminal&nbsp;screen&nbsp;lines&nbsp;as&nbsp;a&nbsp;list,&nbsp;same&nbsp;as&nbsp;GetScreen</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetLinesAsText"><strong>GetLinesAsText</strong></a>(self)</dt><dd><tt>Returns&nbsp;the&nbsp;entire&nbsp;terminal&nbsp;screen&nbsp;as&nbsp;a&nbsp;single&nbsp;big&nbsp;string.&nbsp;Each&nbsp;row<br>
is&nbsp;seperated&nbsp;by&nbsp;\n&nbsp;and&nbsp;blank&nbsp;space&nbsp;represents&nbsp;empty&nbsp;character.</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetRawScreen"><strong>GetRawScreen</strong></a>(self)</dt><dd><tt>Returns&nbsp;the&nbsp;screen&nbsp;as&nbsp;a&nbsp;list&nbsp;of&nbsp;strings.&nbsp;The&nbsp;list&nbsp;will&nbsp;have&nbsp;rows&nbsp;no.&nbsp;of<br>
strings&nbsp;and&nbsp;each&nbsp;string&nbsp;will&nbsp;have&nbsp;columns&nbsp;no.&nbsp;of&nbsp;characters.&nbsp;Blank&nbsp;space<br>
used&nbsp;represents&nbsp;no&nbsp;character.</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetRawScreenRendition"><strong>GetRawScreenRendition</strong></a>(self)</dt><dd><tt>Returns&nbsp;the&nbsp;screen&nbsp;as&nbsp;a&nbsp;list&nbsp;of&nbsp;array&nbsp;of&nbsp;long.&nbsp;The&nbsp;list&nbsp;will&nbsp;have&nbsp;rows<br>
no.&nbsp;of&nbsp;array&nbsp;and&nbsp;each&nbsp;array&nbsp;will&nbsp;have&nbsp;columns&nbsp;no.&nbsp;of&nbsp;longs.&nbsp;The&nbsp;first<br>
8&nbsp;bits&nbsp;of&nbsp;long&nbsp;represents&nbsp;rendition&nbsp;style&nbsp;like&nbsp;bold,&nbsp;italics&nbsp;and&nbsp;etc.<br>
The&nbsp;next&nbsp;4&nbsp;bits&nbsp;represents&nbsp;foreground&nbsp;color&nbsp;and&nbsp;next&nbsp;4&nbsp;bits&nbsp;for<br>
background&nbsp;color.</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetRendition"><strong>GetRendition</strong></a>(self, row, col)</dt><dd><tt>Returns&nbsp;the&nbsp;screen&nbsp;rendition&nbsp;at&nbsp;the&nbsp;location&nbsp;specified&nbsp;by&nbsp;row&nbsp;and&nbsp;col.<br>
The&nbsp;returned&nbsp;value&nbsp;is&nbsp;a&nbsp;long,&nbsp;the&nbsp;first&nbsp;8&nbsp;bits&nbsp;specifies&nbsp;the&nbsp;rendition<br>
style&nbsp;and&nbsp;next&nbsp;4&nbsp;bits&nbsp;for&nbsp;foreground&nbsp;and&nbsp;another&nbsp;4&nbsp;bits&nbsp;for&nbsp;background<br>
color.</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetRows"><strong>GetRows</strong></a>(self)</dt><dd><tt>Returns&nbsp;no.&nbsp;rows&nbsp;in&nbsp;the&nbsp;terminal</tt></dd></dl>

<dl><dt><a name="V102Terminal-GetSize"><strong>GetSize</strong></a>(self)</dt><dd><tt>Returns&nbsp;terminal&nbsp;rows&nbsp;and&nbsp;cols&nbsp;as&nbsp;tuple</tt></dd></dl>

<dl><dt><a name="V102Terminal-ProcessInput"><strong>ProcessInput</strong></a>(self, text)</dt><dd><tt>Processes&nbsp;the&nbsp;given&nbsp;input&nbsp;text.&nbsp;It&nbsp;detects&nbsp;V100&nbsp;escape&nbsp;sequences&nbsp;and<br>
handles&nbsp;it.&nbsp;Any&nbsp;partial&nbsp;unparsed&nbsp;escape&nbsp;sequences&nbsp;are&nbsp;stored&nbsp;internally<br>
and&nbsp;processed&nbsp;along&nbsp;with&nbsp;next&nbsp;input&nbsp;text.&nbsp;Before&nbsp;leaving,&nbsp;the&nbsp;function<br>
calls&nbsp;the&nbsp;callbacks&nbsp;CALLBACK_UPDATE_LINE&nbsp;and&nbsp;CALLBACK_UPDATE_CURSOR_POS<br>
to&nbsp;update&nbsp;the&nbsp;changed&nbsp;lines&nbsp;and&nbsp;cursor&nbsp;position&nbsp;respectively.</tt></dd></dl>

<dl><dt><a name="V102Terminal-Resize"><strong>Resize</strong></a>(self, rows, cols)</dt><dd><tt>Resizes&nbsp;the&nbsp;terminal&nbsp;to&nbsp;specified&nbsp;rows&nbsp;and&nbsp;cols.<br>
-&nbsp;If&nbsp;the&nbsp;new&nbsp;no.&nbsp;rows&nbsp;is&nbsp;less&nbsp;than&nbsp;existing&nbsp;no.&nbsp;rows&nbsp;then&nbsp;existing&nbsp;rows<br>
&nbsp;&nbsp;are&nbsp;deleted&nbsp;at&nbsp;top.<br>
-&nbsp;If&nbsp;the&nbsp;new&nbsp;no.&nbsp;rows&nbsp;is&nbsp;greater&nbsp;than&nbsp;existing&nbsp;no.&nbsp;rows&nbsp;then<br>
&nbsp;&nbsp;blank&nbsp;rows&nbsp;are&nbsp;added&nbsp;at&nbsp;bottom.<br>
-&nbsp;If&nbsp;the&nbsp;new&nbsp;no.&nbsp;cols&nbsp;is&nbsp;less&nbsp;than&nbsp;existing&nbsp;no.&nbsp;cols&nbsp;then&nbsp;existing&nbsp;cols<br>
&nbsp;&nbsp;are&nbsp;deleted&nbsp;at&nbsp;right.<br>
-&nbsp;If&nbsp;the&nbsp;new&nbsp;no.&nbsp;cols&nbsp;is&nbsp;greater&nbsp;than&nbsp;existing&nbsp;no.&nbsp;cols&nbsp;then&nbsp;new&nbsp;cols<br>
&nbsp;&nbsp;are&nbsp;added&nbsp;at&nbsp;right.</tt></dd></dl>

<dl><dt><a name="V102Terminal-ScrollUp"><strong>ScrollUp</strong></a>(self)</dt><dd><tt>Scrolls&nbsp;up&nbsp;the&nbsp;terminal&nbsp;screen&nbsp;by&nbsp;one&nbsp;line.&nbsp;The&nbsp;callbacks<br>
CALLBACK_UPDATE_LINES&nbsp;and&nbsp;CALLBACK_SCROLL_UP_SCREEN&nbsp;are&nbsp;called&nbsp;before<br>
scrolling&nbsp;the&nbsp;screen.</tt></dd></dl>

<dl><dt><a name="V102Terminal-SetCallback"><strong>SetCallback</strong></a>(self, event, func)</dt><dd><tt>Sets&nbsp;callback&nbsp;function&nbsp;for&nbsp;the&nbsp;specified&nbsp;event.&nbsp;The&nbsp;event&nbsp;should&nbsp;be<br>
any&nbsp;one&nbsp;of&nbsp;the&nbsp;following.&nbsp;None&nbsp;can&nbsp;be&nbsp;passed&nbsp;as&nbsp;callback&nbsp;function&nbsp;to<br>
reset&nbsp;the&nbsp;callback.<br>
&nbsp;<br>
CALLBACK_SCROLL_UP_SCREEN<br>
&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;before&nbsp;scrolling&nbsp;up&nbsp;the&nbsp;terminal&nbsp;screen.<br>
&nbsp;<br>
CALLBACK_UPDATE_LINES<br>
&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;ever&nbsp;some&nbsp;lines&nbsp;need&nbsp;to&nbsp;be&nbsp;updated.&nbsp;Usually&nbsp;called<br>
&nbsp;&nbsp;&nbsp;&nbsp;before&nbsp;leaving&nbsp;ProcessInput&nbsp;and&nbsp;before&nbsp;scrolling&nbsp;up&nbsp;the<br>
&nbsp;&nbsp;&nbsp;&nbsp;terminal&nbsp;screen.<br>
&nbsp;<br>
CALLBACK_UPDATE_CURSOR_POS<br>
&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;to&nbsp;update&nbsp;the&nbsp;cursor&nbsp;position.&nbsp;Usually&nbsp;called&nbsp;before&nbsp;leaving<br>
&nbsp;&nbsp;&nbsp;&nbsp;ProcessInput.<br>
&nbsp;<br>
CALLBACK_UPDATE_WINDOW_TITLE<br>
&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;ever&nbsp;a&nbsp;window&nbsp;title&nbsp;escape&nbsp;sequence&nbsp;encountered.&nbsp;The<br>
&nbsp;&nbsp;&nbsp;&nbsp;terminal&nbsp;window&nbsp;title&nbsp;will&nbsp;be&nbsp;passed&nbsp;as&nbsp;a&nbsp;string.<br>
&nbsp;<br>
CALLBACK_UNHANDLED_ESC_SEQ<br>
&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;ever&nbsp;a&nbsp;unsupported&nbsp;escape&nbsp;sequence&nbsp;encountered.&nbsp;The<br>
&nbsp;&nbsp;&nbsp;&nbsp;unhandled&nbsp;escape&nbsp;sequence(escape&nbsp;sequence&nbsp;character&nbsp;and&nbsp;it<br>
&nbsp;&nbsp;&nbsp;&nbsp;parameters)&nbsp;will&nbsp;be&nbsp;passed&nbsp;as&nbsp;a&nbsp;string.</tt></dd></dl>

<dl><dt><a name="V102Terminal-__init__"><strong>__init__</strong></a>(self, rows, cols)</dt><dd><tt>Initializes&nbsp;the&nbsp;terminal&nbsp;with&nbsp;specified&nbsp;rows&nbsp;and&nbsp;columns.&nbsp;User&nbsp;can<br>
resize&nbsp;the&nbsp;terminal&nbsp;any&nbsp;time&nbsp;using&nbsp;Resize&nbsp;method.&nbsp;By&nbsp;default&nbsp;the&nbsp;screen<br>
is&nbsp;cleared(filled&nbsp;with&nbsp;blank&nbsp;spaces)&nbsp;and&nbsp;cursor&nbsp;positioned&nbsp;in&nbsp;the&nbsp;first<br>
row&nbsp;and&nbsp;first&nbsp;column.</tt></dd></dl>

<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>CALLBACK_SCROLL_UP_SCREEN</strong> = 1</dl>

<dl><dt><strong>CALLBACK_UNHANDLED_ESC_SEQ</strong> = 5</dl>

<dl><dt><strong>CALLBACK_UPDATE_CURSOR_POS</strong> = 3</dl>

<dl><dt><strong>CALLBACK_UPDATE_LINES</strong> = 2</dl>

<dl><dt><strong>CALLBACK_UPDATE_WINDOW_TITLE</strong> = 4</dl>

<dl><dt><strong>RENDITION_STYLE_BOLD</strong> = 1</dl>

<dl><dt><strong>RENDITION_STYLE_DIM</strong> = 2</dl>

<dl><dt><strong>RENDITION_STYLE_FAST_BLINK</strong> = 32</dl>

<dl><dt><strong>RENDITION_STYLE_HIDDEN</strong> = 128</dl>

<dl><dt><strong>RENDITION_STYLE_INVERSE</strong> = 64</dl>

<dl><dt><strong>RENDITION_STYLE_ITALIC</strong> = 4</dl>

<dl><dt><strong>RENDITION_STYLE_SLOW_BLINK</strong> = 16</dl>

<dl><dt><strong>RENDITION_STYLE_UNDERLINE</strong> = 8</dl>

</td></tr></table></td></tr></table>
</body></html>